home *** CD-ROM | disk | FTP | other *** search
/ Champak 123 / (Vol 123) Jan 13 2011.iso / Games / ping_ai.swf / scripts / frame_4 / PlaceObject2_25_3 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Text File  |  2011-01-13  |  4KB  |  143 lines

  1. onClipEvent(enterFrame){
  2.    function trajectory()
  3.    {
  4.       angle = Math.atan(ymov / xmov) * 180 / math.pi;
  5.       if(ymov >= 0 and xmov >= 0)
  6.       {
  7.          trajectory = Number(angle);
  8.          quad = 1;
  9.       }
  10.       else if(ymov >= 0 and xmov < 0)
  11.       {
  12.          quad = 2;
  13.          trajectory = 180 + Number(angle);
  14.       }
  15.       else if(ymov < 0 and xmov < 0)
  16.       {
  17.          trajectory = 180 + Number(angle);
  18.          quad = 3;
  19.       }
  20.       else if(ymov < 0 and xmov >= 0)
  21.       {
  22.          trajectory = 360 + Number(angle);
  23.          quad = 4;
  24.       }
  25.    }
  26.    if(this._parent.go == "yes")
  27.    {
  28.       if(this._parent.movie_height < this._y + this._height / 2)
  29.       {
  30.          _Y = this._parent.movie_height - this._height / 2;
  31.          updateAfterEvent();
  32.          ymov = - ymov;
  33.       }
  34.       else if(this._y - this._height / 2 < 0)
  35.       {
  36.          _Y = this._height / 2;
  37.          updateAfterEvent();
  38.          ymov = - ymov;
  39.       }
  40.       if(this._parent.left.hitTest(this) or this._parent.right.hitTest(this))
  41.       {
  42.          if(this._parent.left.hitTest(this))
  43.          {
  44.             paddle = "left";
  45.             _root.Left_s.start();
  46.             _X = this._parent.left._x + this._parent.left._width / 2 + this._width / 2;
  47.             updateAfterEvent();
  48.          }
  49.          else if(this._parent.right.hitTest(this))
  50.          {
  51.             paddle = "right";
  52.             _root.Right_s.start();
  53.             _X = this._parent.right._x - this._parent.right._width / 2 - this._width / 2;
  54.             updateAfterEvent();
  55.          }
  56.          if(this._parent.level == "one")
  57.          {
  58.             factor = 0.1;
  59.          }
  60.          else if(this._parent.level == "two")
  61.          {
  62.             factor = 0.2;
  63.          }
  64.          else if(this._parent.level == "three")
  65.          {
  66.             factor = 0.4;
  67.          }
  68.          current_speed = math.sqrt(xmov * xmov + ymov * ymov) + factor;
  69.          if(_root.filter < current_speed)
  70.          {
  71.             current_speed = _root.filter;
  72.          }
  73.          trajectory();
  74.          if(paddle == "right")
  75.          {
  76.             shift = (- max_shift) * (this._parent.right._y - this._y) / (this._parent.right._height / 2);
  77.          }
  78.          else if(paddle == "left")
  79.          {
  80.             shift = max_shift * (this._parent.left._y - this._y) / (this._parent.left._height / 2);
  81.          }
  82.          trajectory += shift;
  83.          if(rot_filter < trajectory + shift and trajectory + shift < 180 - rot_filter or rot_filter + 180 < trajectory + shift and trajectory + shift < 360 - rot_filter)
  84.          {
  85.             if(0 < trajectory and trajectory < 90)
  86.             {
  87.                trajectory = rot_filter;
  88.             }
  89.             else if(90 < trajectory and trajectory < 180)
  90.             {
  91.                trajectory = 180 - rot_filter;
  92.             }
  93.             else if(180 < trajectory and trajectory < 270)
  94.             {
  95.                trajectory = 180 + rot_filter;
  96.             }
  97.             else if(270 < trajectory and trajectory < 360)
  98.             {
  99.                trajectory = 360 - rot_filter;
  100.             }
  101.          }
  102.          angle = trajectory * math.pi / 180;
  103.          xmov = current_speed * math.cos(angle);
  104.          ymov = current_speed * math.sin(angle);
  105.          xmov = - xmov;
  106.       }
  107.       _Y = this._y + ymov;
  108.       _X = this._x + xmov;
  109.       ball_shift = 0;
  110.       if(this._x < -20)
  111.       {
  112.          _root.Out.start();
  113.          _Y = 150;
  114.          _X = 300;
  115.          setProperty("_root.popup", _visible, 1);
  116.          if(_root.level == "one")
  117.          {
  118.             _root.popup.gotoAndStop(3);
  119.          }
  120.          else if(_root.level == "two")
  121.          {
  122.             _root.popup.gotoAndStop(4);
  123.          }
  124.          else if(_root.level == "three")
  125.          {
  126.             _root.popup.gotoAndStop(5);
  127.          }
  128.          xmov = 0;
  129.          ymov = 0;
  130.       }
  131.       else if(this._parent.movie_width + 20 < this._x)
  132.       {
  133.          _root.Out.start();
  134.          _Y = 150;
  135.          _X = 300;
  136.          setProperty("_root.popup", _visible, 1);
  137.          _root.popup.gotoAndStop(2);
  138.          xmov = 0;
  139.          ymov = 0;
  140.       }
  141.    }
  142. }
  143.